//
//  ScketSvr.h
//  WiFiScale
//
//  Created by Yongfeng Li on 11/20/10.
//  Copyright 2010 Nci Technology Inc. All rights reserved.
//

#import <Foundation/Foundation.h>
//#include <netdb.h>
//#include <arpa/inet.h>


@protocol NcitWiFiDevDelegate <NSObject>

@optional
- (void) recvedWiFiScaleData: (NSMutableString *) sLine;
- (void) recvedWiFiHexData:(UInt8*)pData len:(int)nLen;

- (void) sendingDataProgress:(float)fStep xPos:(float)x yPos:(float)y;
- (void) finishedDataSending;

- (void) connFailed;
- (void) closeSocket;

@end

@interface NcitWiFiDev : NSObject /*<NSStreamDelegate>*/ {
   
	/*id<SocketSvrDelegate>__unsafe_unretained svrDelegate;
    NSArray* __unsafe_unretained m_dataSent;
    NSMutableString* __unsafe_unretained _sLine;*/
}

@property (strong) id<NcitWiFiDevDelegate> svrDelegate;
@property (strong) NSArray *m_dataSent;
@property(strong) NSMutableString *_sLine;

@property (nonatomic, assign) in_addr_t m_nIpAddr;
@property (nonatomic, assign) uint16_t m_nPort;


-(id) init;
-(id)init:(in_addr_t)nIpAddr port: (uint16_t)nPort;
-(id) setAddrPort:(in_addr_t)nIpAddr port: (uint16_t)nPort;
-(void) setTypeIdx:(int)nIdx;

- (BOOL) sendDataOn:(char *)sMsg Alert:(BOOL) bShow;
- (BOOL) syncDataOn:(char *)sMsg Alert:(BOOL) bShow;
- (BOOL) userSignin:(char *) sMsg Alert:(BOOL) bShow;

- (BOOL) turnConnOn;
- (void) turnConnOff;
- (BOOL) isConnNetwork;

- (BOOL) sendData:(char *)sMsg Alert:(BOOL)bShow;
- (BOOL) sendHexData:(UInt8*) pData alert:(BOOL)bShow;
//- (void) sendDataOut:(CFSocketNativeHandle)sock;

- (BOOL) start:(in_addr_t)nIpAddr ErrMsg:(NSError **)error;
//- (BOOL) startUdp:(in_addr_t)nIpAddr port: (uint16_t)nPort ErrMsg:(NSError **)error;
- (BOOL) startUdp:(struct sockaddr_in)addr4 ErrMsg:(NSError **)error;

- (BOOL) startOn;
- (BOOL) stop;

- (void) bkgdKeepConn;

@end

/************************************/
